home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb-4.5 / ds3100.md / gdb / RCS / mips-xdep.c,v < prev    next >
Encoding:
Text File  |  1992-07-01  |  4.4 KB  |  206 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     92.06.17.11.48.44;  author secor;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/* Low level MIPS interface to ptrace, for GDB when running under Unix.
  26.    Copyright 1988, 1989, 1991, 1992 Free Software Foundation, Inc.
  27.    Contributed by Alessandro Forin(af@@cs.cmu.edu) at CMU
  28.    and by Per Bothner(bothner@@cs.wisc.edu) at U.Wisconsin.
  29.  
  30. This file is part of GDB.
  31.  
  32. This program is free software; you can redistribute it and/or modify
  33. it under the terms of the GNU General Public License as published by
  34. the Free Software Foundation; either version 2 of the License, or
  35. (at your option) any later version.
  36.  
  37. This program is distributed in the hope that it will be useful,
  38. but WITHOUT ANY WARRANTY; without even the implied warranty of
  39. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  40. GNU General Public License for more details.
  41.  
  42. You should have received a copy of the GNU General Public License
  43. along with this program; if not, write to the Free Software
  44. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  45.  
  46. #include "defs.h"
  47. #include <mips/inst.h>
  48. #include "frame.h"
  49. #include "inferior.h"
  50. #include "symtab.h"
  51. #include "value.h"
  52.  
  53. #ifdef USG
  54. #include <sys/types.h>
  55. #endif
  56.  
  57. #include <sys/param.h>
  58. #include <sys/dir.h>
  59. #include <signal.h>
  60. #include <sys/ioctl.h>
  61. /* #include <fcntl.h>  Can we live without this?  */
  62.  
  63. #include "gdbcore.h"
  64.  
  65. #include <sys/user.h>        /* After a.out.h  */
  66. #include <sys/file.h>
  67. #include <sys/stat.h>
  68.  
  69. /* For now we stub this out; sgi format is super-hairy (and completely
  70.    different in the new release) */
  71.  
  72. #ifdef sgi
  73. void
  74. fetch_core_registers ()
  75. {
  76.   return;
  77. }
  78.  
  79. /* ARGSUSED */
  80. void
  81. fetch_inferior_registers (regno)
  82.      int regno;
  83. {
  84.   return;
  85. }
  86.  
  87. /* ARGSUSED */
  88. void
  89. store_inferior_registers (regno)
  90.      int regno;
  91. {
  92.   return;
  93. }
  94.  
  95.  
  96. #else
  97.  
  98. /* Map gdb internal register number to ptrace address. */
  99.  
  100. #define REGISTER_PTRACE_ADDR(regno) \
  101.  (regno < 32 ? regno         \
  102.   : regno == PC_REGNUM ? 96    \
  103.   : regno == CAUSE_REGNUM ? 97    \
  104.   : regno == HI_REGNUM ? 98    \
  105.   : regno == LO_REGNUM ? 99    \
  106.   : regno == FCRCS_REGNUM ? 100    \
  107.   : regno == FCRIR_REGNUM ? 101    \
  108.   : regno >= FP0_REGNUM ? regno - (FP0_REGNUM-32)\
  109.   : 0)
  110.  
  111. /* Get all registers from the inferior */
  112.  
  113. void
  114. fetch_inferior_registers (regno)
  115.      int regno;
  116. {
  117.   register unsigned int regaddr;
  118.   char buf[MAX_REGISTER_RAW_SIZE];
  119.   register int i;
  120.  
  121.   registers_fetched ();
  122.  
  123.   for (regno = 1; regno < NUM_REGS; regno++)
  124.     {
  125.       regaddr = REGISTER_PTRACE_ADDR (regno);
  126.       for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
  127.      {
  128.        *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0);
  129.        regaddr += sizeof (int);
  130.      }
  131.       supply_register (regno, buf);
  132.     }
  133. }
  134.  
  135. /* Store our register values back into the inferior.
  136.    If REGNO is -1, do this for all registers.
  137.    Otherwise, REGNO specifies which register (so we can save time).  */
  138.  
  139. void
  140. store_inferior_registers (regno)
  141.      int regno;
  142.  {
  143.   register unsigned int regaddr;
  144.   char buf[80];
  145.  
  146.   if (regno == 0)
  147.     return;
  148.  
  149.   if (regno > 0)
  150.     {
  151.       regaddr = REGISTER_PTRACE_ADDR (regno);
  152.       errno = 0;
  153.       ptrace (6, inferior_pid, regaddr, read_register (regno));
  154.       if (errno != 0)
  155.     {
  156.       sprintf (buf, "writing register number %d", regno);
  157.       perror_with_name (buf);
  158.     }
  159.     }
  160.   else
  161.     {
  162.       for (regno = 0; regno < NUM_REGS; regno++)
  163.     {
  164.       if (regno == ZERO_REGNUM || regno == PS_REGNUM
  165.           || regno == BADVADDR_REGNUM || regno == CAUSE_REGNUM
  166.           || regno == FCRIR_REGNUM || regno == FP_REGNUM
  167.           || (regno >= FIRST_EMBED_REGNUM && regno <= LAST_EMBED_REGNUM))
  168.         continue;
  169.       regaddr = register_addr (regno, 1);
  170.       errno = 0;
  171.       ptrace (6, inferior_pid, regaddr, read_register (regno));
  172.       if (errno != 0)
  173.         {
  174.           sprintf (buf, "writing all regs, number %d", regno);
  175.           perror_with_name (buf);
  176.         }
  177.     }
  178.     }
  179. }
  180.  
  181. #endif /* sgi */
  182.  
  183. #if 0
  184. void
  185. fetch_core_registers ()
  186. {
  187.   register int regno;
  188.   int val;
  189.  
  190.   for (regno = 1; regno < NUM_REGS; regno++) {
  191.     char buf[MAX_REGISTER_RAW_SIZE];
  192.  
  193.     val = bfd_seek (core_bfd, register_addr (regno, 0));
  194.     if (val < 0 || (val = bfd_read (core_bfd, buf, sizeof buf)) < 0) {
  195.       char buffer[50];
  196.       strcpy (buffer, "Reading register ");
  197.       strcat (buffer, reg_names[regno]);
  198.  
  199.       perror_with_name (buffer);
  200.     }
  201.     supply_register (regno, buf);
  202.   }
  203. }
  204. #endif /* 0 */
  205. @
  206.